from django.db import models
from commodity.models import *
# Create your models here.

# 订单状态
STATE = (
    ('待支付','待支付'),
    ('已支付','已支付'),
    ('发货中','发货中'),
    ('已签收','已签收'),
    ('退货中','退货中')
)
# 购物车表
class CarInfo(models.Model):
    id = models.AutoField(primary_key=True)
    quantity = models.IntegerField(verbose_name='购买数量',default=1)
    commodity_id = models.ForeignKey(Product,on_delete=models.CASCADE,verbose_name='商品id')
    user_id = models.IntegerField(verbose_name='用户id')
    created = models.DateField(auto_now_add=True, verbose_name='购买时间')
    state = models.CharField(max_length=50, choices=STATE)

    class Meta:
        db_table = 'car_info'
        verbose_name = '购物车'
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.commodity_id.name
